<?php 
	
		session_start();
		include('system/db/conn.php');
		
		$content = $_POST['name'];
		//var_dump($content);
		
		$userid=$_SESSION['userid'];
		//var_dump($userid);
		$sid=$_POST['sid'];
		$cod = time();
		//var_dump($cod);
		if($content!="daishuaige"){
		$sql = "insert into do_message(content,create_time,user_id,supplier_id) values('$content','$cod','$userid','".$sid."')";
		
		if(mysql_query($sql,$conn)){

			//echo "提交留言成功！";
			
			$sql_message="SELECT m.content,m.create_time,u.user_name,m.admin_reply FROM do_message m,do_user u where m.user_id = u.id and m.supplier_id=".$sid."  order by m.create_time desc limit 4";

			$result = mysql_query($sql_message);
			
			header("Content-Type:text/xml"); //php 

			echo '<?xml version="1.0" encoding="UTF-8"?><comment>';
			
			while($row = mysql_fetch_array($result))
			 {
			 	 echo "<pcomment>";
				 echo "<content>" . $row['content'] . "</content>";
				 echo "<createtime>" . date("Y-m-j H:i:s",$row['create_time']). "</createtime>";
				 echo "<username>" . $row['user_name'] . "</username>";
				 echo "<adminreply>".$row['admin_reply']."</adminreply>";
				  echo "</pcomment>";
			 }
			  mysql_free_result($result);
				echo "</comment>";

		}
	}else{


 
			//echo "提交留言成功！";
			
			$sql_message="SELECT m.content,m.create_time,u.user_name,m.admin_reply FROM do_message m,do_user u  where m.user_id = u.id and m.supplier_id=".$sid." order by m.create_time desc limit 4";

			$result = mysql_query($sql_message);
			
			header("Content-Type:text/xml"); //php 

			echo '<?xml version="1.0" encoding="UTF-8"?><comment>';
			
			while($row = mysql_fetch_array($result))
			 {
			 	 echo "<pcomment>";
				 echo "<content>" . $row['content'] . "</content>";
				 echo "<createtime>" . date("Y-m-j H:i:s",$row['create_time']) . "</createtime>";
				 echo "<username>" . $row['user_name'] . "</username>";
				 echo "<adminreply>".$row['admin_reply']."</adminreply>";
				  echo "</pcomment>";
			 }
			     mysql_free_result($result);
				echo "</comment>";

	}
		


?>